var _path = '/zpmng/';
//url:form add and edit jsp
var _formAddEditUrl = "/admin123/coding/owDoorRespInfo/add_edit.jsp";
//url:form add action
var _formAddAction = "/admin123/coding/owDoorRespInfo/owDoorRespInfoAjax_addData.action";
//url:form edit action
var _formEditAction = "/admin123/coding/owDoorRespInfo/owDoorRespInfoAjax_editData.action";
//url:form remove action
var _formRemoveAction = "/admin123/coding/owDoorRespInfo/owDoorRespInfoAjax_removeData.action";
//url:report
var _formReportAction = "/admin123/coding/owDoorRespInfo/add_edit.jsp";


var _keyRandom = 'ow_door_resp_info';
//上个页面通过右击列表 传过来的 id和row; ps:右击模板x列，看模板列列表，自动加载列数，要传模板id找表名
var _prePageListRow = '${paramValues.row[0]}';
_prePageListRow = decodeURI(_prePageListRow);
var _prePageListId = '${paramValues._id[0]}';

//template table foreign key
var _foreignKey = '0';
var _primaryKey = 'id';

//add dialog width and height
var _width4AddDialog = '0';
var _height4AddDialog = '0';
if (_width4AddDialog == '' || _width4AddDialog == '0') _width4AddDialog = 800;
if (_height4AddDialog == '' || _height4AddDialog == '0') _height4AddDialog = 400;
//dialog style, 取代上面的方法
var _isdialog4AddDialog = '1';
var _style4AddDialog = 'width:1200px;height:600px;';
if (_style4AddDialog == '') _style4AddDialog = 'width:800px;height:400px';


/*
	hidden fileds when option has changed
	选择optionId时，filedList是要隐藏的域
	结构如下 ：
	var hiddenFileds = [
		{"optionId":"11","filedList":[{"text":"foreignkey"},{"text":"tablenamesql"}]},
		{"optionId":"12","filedList":[{"text":"tablenamehistorysql"},{"text":"sqlsum"}]}
	];
*/
var hiddenFileds = []


/**
 页面datagrid控件显示列元素：datagrid.columns
 */
var datagrid_columns = [[
    // {"field":"id","width":100,"title":"ID"},
    {"field": "entName", "width": 100, "title": "企业名称"},
    {"field": "entShopName", "width": 100, "title": "店招名"},
    {"field": "signPic", "width": 100, "title": "签名"},
    {"field": "entFormat", "width": 100, "title": "业态"},
    {"field": "entDetailAdd", "width": 100, "title": "详细地址"},
    {"field": "entOwner", "width": 100, "title": "业主方"},
    {"field": "entProperty", "width": 100, "title": "所属物业"},
    {"field": "entSocialCreditCode", "width": 100, "title": "统一社会信用代码"},
    {"field": "entManageArea", "width": 100, "title": "经营面积"},
    {"field": "entLegalPerson", "width": 100, "title": "法定代表人"},
    {"field": "entLpTel", "width": 100, "title": "法人联系电话"},
    {"field": "entRespPerson", "width": 100, "title": "负责人"},
    {"field": "entRpTel", "width": 100, "title": "负责人联系电话"},
    {"field": "entType", "hidden": "true", "title": "企业类型"}, {"field": "entType_Str", "width": 100, "title": "企业类型"},
    {"field": "cookWasteCollectUnit", "width": 100, "title": "餐厨废弃油脂收运单位"},
    {"field": "cookDeviceInstall", "hidden": "true", "title": "油水分类装置安装情况"}, {
        "field": "cookDeviceInstall_Str",
        "width": 100,
        "title": "油水分类装置安装情况"
    },
    {"field": "cookCollectCarNo", "width": 100, "title": "收运车辆车牌号"},
    {"field": "cookCollectRate", "width": 100, "title": "收运频率"},
    {"field": "cookCollectTime", "width": 100, "title": "收运具体时间"},
    {"field": "cookPurityUnit", "width": 100, "title": "油烟净化装置清晰单位"},
    {"field": "cookCleanRate", "width": 100, "title": "清洗频率"},
    {"field": "cookHasCertificate", "hidden": "true", "title": "清洗单位有无资质证书"}, {
        "field": "cookHasCertificate_Str",
        "width": 100,
        "title": "清洗单位有无资质证书"
    },
    {"field": "dgClearUnit", "width": 100, "title": "生活垃圾清运单位"},
    {"field": "dgClearRate", "width": 100, "title": "清运频率"},
    {"field": "dgType","hidden": "true","title": "生活垃圾种类"},
    {
        "field":"dgType_Str",
        "width":100,
        "title":"生活垃圾种类"
    },
    {"field": "waterHasLicence", "hidden": "true", "title": "是否有排水许可证"}, {
        "field": "waterHasLicence_Str",
        "width": 100,
        "title": "是否有排水许可证"
    },
    {"field": "waterLicenceNo", "width": 100, "title": "许可证编号"},
    {"field": "advShopBrandType", "hidden": "true", "title": "店招类型"}, {
        "field": "advShopBrandType_Str",
        "width": 100,
        "title": "店招类型"
    },
    {"field": "advShopBrandContent", "width": 100, "title": "店招内容"},
    {"field": "advShopLinkman", "width": 100, "title": "店招联系人"},
    {"field": "advShopTel", "width": 100, "title": "店招联系方式"},
    {"field": "advShopApproval", "hidden": "true", "title": "店招审批信息"}, {
        "field": "advShopApproval_Str",
        "width": 100,
        "title": "店招审批信息"
    },
    {"field": "advApprovalNo", "width": 100, "title": "店招审批编号"},
    {"field": "advShopApprovalTerm", "width": 100, "title": "店招审批期限"},
    {"field": "advShopSetYear", "width": 100, "title": "店招设置年份"},
    {"field": "advShopSetNum", "width": 100, "title": "设置数量"},
    {"field": "advShopSize", "width": 100, "title": "尺寸"},
    {"field": "advShopSetHeight", "hidden": "true", "title": "店招设置高度"}, {
        "field": "advShopSetHeight_Str",
        "width": 100,
        "title": "店招设置高度"
    },
    {"field": "advHeight", "width": 100, "title": "广告设置高度"},
    {"field": "advShopStructureType", "hidden": "true", "title": "店招结构类型"}, {
        "field": "advShopStructureType_Str",
        "width": 100,
        "title": "店招结构类型"
    },
    {"field": "advShopMaterial", "width": 100, "title": "店招材质"},
    {"field": "advShopSetType", "hidden": "true", "title": "店招设置方式"}, {
        "field": "advShopSetType_Str",
        "width": 100,
        "title": "店招设置方式"
    },
    {"field": "advStructureType", "hidden": "true", "title": "结构类型"}, {
        "field": "advStructureType_Str",
        "width": 100,
        "title": "结构类型"
    },
    {"field": "advMaterial", "hidden": true, "title": "材质"}, {
        "field": "advMaterial_Str",
        "width": 100,
        "title": "材质"
    },
    {"field": "userId", "width": 100, "title": "用户ID"},
    {"field": "insertFlag", "hidden": "true", "title": "录入方式"}, {
        "field": "insertFlag_Str",
        "width": 100,
        "title": "录入方式"
    },
    {"field": "advShopApprovalNo", "width": 100, "title": "审批编号"},
    {"field": "advBrandType", "hidden": "true", "title": "户外广告类型"}, {
        "field": "advBrandType_Str",
        "width": 100,
        "title": "户外广告类型"
    },
    {"field": "advContent", "width": 100, "title": "广告内容"},
    {"field": "advPlaceOwner", "width": 100, "title": "阵地所有方"},
    {"field": "advPlaceLinkman", "width": 100, "title": "联系人"},
    {"field": "advPlaceTel", "width": 100, "title": "联系方式"},
    {"field": "advSetParty", "width": 100, "title": "设置方"},
    {"field": "advSetPartyLinkman", "width": 100, "title": "联系人"},
    {"field": "advSetPartyTel", "width": 100, "title": "联系方式"},
    {"field": "advApproval", "hidden": "true", "title": "审批信息"}, {
        "field": "advApproval_Str",
        "width": 100,
        "title": "审批信息"
    },
    {"field": "advApprovalTermVar", "width": 100, "title": "审批期限"},
    {"field": "advApprovalTermDate", "width": 100, "title": "审批期限日期型"},
    {"field": "advSetNum", "width": 100, "title": "设置数量（块）"},
    {"field": "advSize", "width": 100, "title": "尺寸"},
    {"field": "advSetMode", "hidden": "true", "title": "设置方式"},    {
        "field": "advSetMode_Str",
        "width": 100,
        "title": "设置方式"
    },
    {"field": "advHeight", "hidden": "true", "title": "设置高度"},
    {
        "field": "advHeight_Str",
        "width": 100,
        "title": "设置高度"
    },
    {"field": "advFacilityAddr", "width": 100, "title": "广告设施所处地址"},
    {"field": "advLocation", "width": 100, "title": "所处位置"},
    {"field": "parkHave", "hidden": "true", "title": "是否有停车库"},
    {
        "field":"parkHave_Str",
        "width":100,
        "title":"是否有停车库"
    },
    {"field": "parkRegAddr", "width": 100, "title": "注册地址"},
    {"field": "parkPlaceAddr", "width": 100, "title": "场（库）地址"},
    {"field": "parkRecordCardNo", "width": 100, "title": "备案证号"},
    {"field": "parkRecordDate", "width": 100, "title": "备案日期"},
    {"field": "parkRespPerson", "width": 100, "title": "场（库）联系人"},
    {"field": "parkRespPersonTel", "width": 100, "title": "联系电话"},
    {"field": "parkPropertyNature", "width": 100, "title": "场（库）产权性质"},
    {"field": "parkLotSum", "width": 100, "title": "停车场（库）总泊位数"},
    {"field": "parkPlaceType", "hidden": "true", "title": "场（库）性质（可多选）"}, {
        "field": "parkPlaceType_Str",
        "width": 100,
        "title": "场（库）性质（可多选）"
    },
    {"field": "parkLotNum", "width": 100, "title": "停车场泊位数"},
    {"field": "parkLotFreightBasis", "width": 100, "title": "计费标准"},
    {"field": "parkGarageNum", "width": 100, "title": "停车库泊位数"},
    {"field": "parkGarageFreightBasis", "width": 100, "title": "计费标准"},
    {"field": "parkOnline", "hidden": "true", "title": "停车场信息联网"}, {
        "field": "parkOnline_Str",
        "width": 100,
        "title": "停车场信息联网"
    },
    {"field": "parkServiceTime", "width": 100, "title": "服务时间"},
    {"field": "parkServiceTel", "width": 100, "title": "对外服务电话"},
    {"field": "parkHotline", "width": 100, "title": "监督电话"},
    {"field": "deleteflag", "hidden": "true", "title": "删除标志"}, {
        "field": "deleteflag_Str",
        "width": 100,
        "title": "删除标志"
    },

    {"field": "createmanId", "width": 100, "title": "createman_id", "hidden": true},
    {"field": "modifymanId", "width": 100, "title": "modifyman_id", "hidden": true},
    {"field": "companyId", "width": 100, "title": "company_id", "hidden": true},
    {"field": "createdate", "width": 100, "title": "创建日期"},
    {"field": "createman", "width": 100, "title": "创建人"},
    {"field": "modifydate", "width": 100, "title": "修改日期"},
    {"field": "modifyman", "width": 100, "title": "修改人"},
    {
        "formatter": function (value, rowData, rowIndex) {
            if (typeof (rowData.id) == 'undefined') {
                return '';
            }
            ;
            var btn = '';
            btn += '<a linetail=\"edit\" class=\"editcls\" style=\"height:20px;\" ' +
            //     'onclick=\"editRow(' + rowIndex + ')\" href=\"javascript:void(0)\">编辑<\/a>';
            // btn += '<a linetail=\"del\" class=\"delcls\" style=\"height:20px;\" ' +
                'onclick=\"removeRow(' + rowIndex + ')\" href=\"javascript:void(0)\">删除<\/a>';
            return btn;
        },
        "field": "opt", "width": 160, "title": "操作", "align": "center"
    }]]


/**
 页面datagrid控件显示列元素：datagrid.frozenColumns
 */
var datagrid_frozenColumns = []
var jarrTmp = [];
var jo = {
    "formatter": function (value, rowData, rowIndex) {
        if (typeof (rowData.id) == 'undefined') {
            return '';
        }
        ;
        var btn = '';
        btn += '<a rowIndex=\"' + rowIndex + '\" class=\"button\" style=\"height:16px;\"  href=\"javascript:void(0)\">菜单<\/a>';
        return btn;
    },
    "field": "menuItem",
    "width": 70,
    "title": "菜单列表",
    "align": "center",
    "hidden": false
};
var jarr = [];
// jarr.push(jo);
$.each(jarrTmp, function (index, value) {
    jarr.push(jarrTmp[index]);
})
datagrid_frozenColumns.push(jarr);


/**
 页面datagrid控件显示列元素：datagrid.toolbarBtns
 */
var datagrid_toolbarBtns = [];
/*datagrid_toolbarBtns[datagrid_toolbarBtns.length] = {
    id: 'toolbarAddBtnId', text: '添加',
    iconCls: 'icon-add',
    handler: function () {
        toolbar_add();
    }
}*/


/**
 datagrid ，后面在condition.js中init了
 */
var datagrid = {
    datagridId: "list",
    datagridUrl: "owDoorRespInfoAjax_queryListBySearch.action",
    datagridObj: {
        /*title:"查询列表",*/
        nowrap: true,
        autoRowHeight: false,
        fit: true,
        columns: datagrid_columns,//datasoure in data.js
        frozenColumns: datagrid_frozenColumns,
        toolbar: datagrid_toolbarBtns,
        rownumbers: true,
        showFooter: true,
        onRowContextMenu: onRowContextMenu
    }
};


var isFirstLoadSuccess = true;
datagrid.datagridObj.onLoadSuccess = function () {
    $('#' + datagrid.datagridId).datagrid('loaded');
    $("#queryBtn_Filter").removeAttr("disabled");
    $('.editcls').linkbutton({plain: true, iconCls: 'icon-edit'});  //给每行后的button加easyui样式
    $('.delcls').linkbutton({plain: true, iconCls: 'icon-remove'});
    //行尾button显示或隐藏
    $("[linetail='edit']").hide();
    authRequestUrl(_formEditAction, function (authResult) {
        if (authResult) {
            $("[linetail='edit']").show();
        }
    });
    $("[linetail='del']").hide();
    authRequestUrl(_formRemoveAction, function (authResult) {
        if (authResult) {
            $("[linetail='del']").show();
        }
    });

    //根据防问权限控制toolbar button显示或隐藏
    if (isFirstLoadSuccess) {
        $('#toolbarAddBtnId').hide();
        authRequestUrl(_formAddAction, function (authResult) {
            if (authResult) {
                $('#toolbarAddBtnId').show();
            }
        });
        isFirstLoadSuccess = false;
    }


    //行首菜单button,打开菜单列表
    $.each($("a"), function (index, value) {
        var obj = $(this);
        var rowIndex1 = obj.attr("rowIndex");
        if (rowIndex1 != undefined) {
            obj.mouseover(function (e) {
                var obj = $(this);
                var offset = obj.offset();
                e.preventDefault();
                rowIndex = rowIndex1;
                var selected = $("#list").datagrid('getRows'); //获取所有行集合对象
                if (selected[rowIndex] == null) {
                    return;
                }
                id = selected[rowIndex].id; //index为当前右键行的索引，指向当前行对象
                $('#rightMenuDiv').menu('show', {
                    left: offset.left + 47,
                    top: offset.top - 5
                });
            });
        }
    });
};


//添加右击菜单内容
var id;
var rowIndex;

function onRowContextMenu(e, rowIndex1, rowData) {
    e.preventDefault();
    rowIndex = rowIndex1;
    var selected = $("#list").datagrid('getRows'); //获取所有行集合对象
    if (selected[rowIndex] == null) {
        return;
    }
    id = selected[rowIndex].id; //index为当前右键行的索引，指向当前行对象
    $('#rightMenuDiv').menu('show', {
        left: e.pageX,
        top: e.pageY
    });
};


/**
 打开AddDialog时，加载默认值
 */
var _defaultValueJOStr = {}


/**
 所有列备份一下，一会隐藏了，可以恢复
 */
var _columnDivArray = new Array();
_columnDivArray[_columnDivArray.length] = '#_ent_name_line';
_columnDivArray[_columnDivArray.length] = '#_ent_shop_name_line';
_columnDivArray[_columnDivArray.length] = '#_ent_format_line';
_columnDivArray[_columnDivArray.length] = '#_ent_detail_add_line';
_columnDivArray[_columnDivArray.length] = '#_ent_owner_line';
_columnDivArray[_columnDivArray.length] = '#_ent_property_line';
_columnDivArray[_columnDivArray.length] = '#_ent_social_credit_code_line';
_columnDivArray[_columnDivArray.length] = '#_ent_manage_area_line';
_columnDivArray[_columnDivArray.length] = '#_ent_legal_person_line';
_columnDivArray[_columnDivArray.length] = '#_ent_lp_tel_line';
_columnDivArray[_columnDivArray.length] = '#_ent_resp_person_line';
_columnDivArray[_columnDivArray.length] = '#_ent_rp_tel_line';
_columnDivArray[_columnDivArray.length] = '#_ent_type_line';
_columnDivArray[_columnDivArray.length] = '#_cook_waste_collect_unit_line';
_columnDivArray[_columnDivArray.length] = '#_cook_device_install_line';
_columnDivArray[_columnDivArray.length] = '#_cook_collect_car_no_line';
_columnDivArray[_columnDivArray.length] = '#_cook_collect_rate_line';
_columnDivArray[_columnDivArray.length] = '#_cook_collect_time_line';
_columnDivArray[_columnDivArray.length] = '#_cook_purity_unit_line';
_columnDivArray[_columnDivArray.length] = '#_cook_clean_rate_line';
_columnDivArray[_columnDivArray.length] = '#_cook_has_certificate_line';
_columnDivArray[_columnDivArray.length] = '#_dg_clear_unit_line';
_columnDivArray[_columnDivArray.length] = '#_dg_clear_rate_line';
_columnDivArray[_columnDivArray.length] = '#_dg_type_line';
_columnDivArray[_columnDivArray.length] = '#_water_has_licence_line';
_columnDivArray[_columnDivArray.length] = '#_water_licence_no_line';
_columnDivArray[_columnDivArray.length] = '#_adv_shop_brand_type_line';
_columnDivArray[_columnDivArray.length] = '#_adv_shop_brand_content_line';
_columnDivArray[_columnDivArray.length] = '#_adv_shop_linkman_line';
_columnDivArray[_columnDivArray.length] = '#_adv_shop_tel_line';
_columnDivArray[_columnDivArray.length] = '#_adv_shop_approval_line';
_columnDivArray[_columnDivArray.length] = '#_adv_approval_no_line';
_columnDivArray[_columnDivArray.length] = '#_adv_shop_approval_term_line';
_columnDivArray[_columnDivArray.length] = '#_adv_shop_set_year_line';
_columnDivArray[_columnDivArray.length] = '#_adv_shop_set_num_line';
_columnDivArray[_columnDivArray.length] = '#_adv_shop_size_line';
_columnDivArray[_columnDivArray.length] = '#_adv_shop_set_height_line';
_columnDivArray[_columnDivArray.length] = '#_adv_height_line';
_columnDivArray[_columnDivArray.length] = '#_adv_shop_structure_type_line';
_columnDivArray[_columnDivArray.length] = '#_adv_shop_material_line';
_columnDivArray[_columnDivArray.length] = '#_adv_shop_set_type_line';
_columnDivArray[_columnDivArray.length] = '#_adv_structure_type_line';
_columnDivArray[_columnDivArray.length] = '#_adv_material_line';
_columnDivArray[_columnDivArray.length] = '#_user_id_line';
_columnDivArray[_columnDivArray.length] = '#_insert_flag_line';
_columnDivArray[_columnDivArray.length] = '#_adv_shop_approval_no_line';
_columnDivArray[_columnDivArray.length] = '#_adv_brand_type_line';
_columnDivArray[_columnDivArray.length] = '#_adv_content_line';
_columnDivArray[_columnDivArray.length] = '#_adv_place_owner_line';
_columnDivArray[_columnDivArray.length] = '#_adv_place_linkman_line';
_columnDivArray[_columnDivArray.length] = '#_adv_place_tel_line';
_columnDivArray[_columnDivArray.length] = '#_adv_set_party_line';
_columnDivArray[_columnDivArray.length] = '#_adv_set_party_linkman_line';
_columnDivArray[_columnDivArray.length] = '#_adv_set_party_tel_line';
_columnDivArray[_columnDivArray.length] = '#_adv_approval_line';
_columnDivArray[_columnDivArray.length] = '#_adv_approval_term_var_line';
_columnDivArray[_columnDivArray.length] = '#_adv_approval_term_date_line';
_columnDivArray[_columnDivArray.length] = '#_adv_set_num_line';
_columnDivArray[_columnDivArray.length] = '#_adv_size_line';
_columnDivArray[_columnDivArray.length] = '#_adv_set_mode_line';
_columnDivArray[_columnDivArray.length] = '#_park_reg_addr_line';
_columnDivArray[_columnDivArray.length] = '#_park_place_addr_line';
_columnDivArray[_columnDivArray.length] = '#_park_record_card_no_line';
_columnDivArray[_columnDivArray.length] = '#_park_record_date_line';
_columnDivArray[_columnDivArray.length] = '#_park_resp_person_line';
_columnDivArray[_columnDivArray.length] = '#_park_resp_person_tel_line';
_columnDivArray[_columnDivArray.length] = '#_park_property_nature_line';
_columnDivArray[_columnDivArray.length] = '#_park_lot_sum_line';
_columnDivArray[_columnDivArray.length] = '#_park_place_type_line';
_columnDivArray[_columnDivArray.length] = '#_park_lot_num_line';
_columnDivArray[_columnDivArray.length] = '#_park_lot_freight_basis_line';
_columnDivArray[_columnDivArray.length] = '#_park_garage_num_line';
_columnDivArray[_columnDivArray.length] = '#_park_garage_freight_basis_line';
_columnDivArray[_columnDivArray.length] = '#_park_online_line';
_columnDivArray[_columnDivArray.length] = '#_park_service_time_line';
_columnDivArray[_columnDivArray.length] = '#_random_key_line';
_columnDivArray[_columnDivArray.length] = '#_park_service_tel_line';
_columnDivArray[_columnDivArray.length] = '#_park_hotline_line';


